home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / gchess40.lha / gnuchess4.0p62 / src / membkstats.c < prev    next >
C/C++ Source or Header  |  1993-06-22  |  2KB  |  84 lines

  1. #include <stdio.h>
  2. FILE *fd;
  3. static struct bookentry
  4. {
  5.   unsigned long bookkey;
  6.   unsigned long bookbd;
  7.   unsigned short bmove;
  8.   unsigned short hint;
  9.   unsigned short count;
  10.   unsigned short flags;
  11. } BEND;
  12. int i;
  13. int booksize, bookmv, bookpocket, bookcount;
  14. int c1 = 0;
  15. int in = 0;
  16. int max = -9999;
  17. int min = 9999999;
  18. int n = 0;
  19. int sum = 0;
  20. int sumc = 0;
  21. int even = 0;
  22. int odd = 0;
  23. main (argc, argv)
  24.      int argc;
  25.      char **argv;
  26. {
  27.   fd = fopen (argv[1], "r");
  28.   if (fd != NULL)
  29.     {
  30.       fscanf (fd, "%d\n", &booksize);
  31.       fscanf (fd, "%d\n", &bookcount);
  32.       fscanf (fd, "%d\n", &bookpocket);
  33.       printf ("entrysize %d\nbooksize %d\nbookpocket %d\nbookcount %d\n", sizeof (struct bookentry), booksize, bookpocket, bookcount);
  34.       for (i = 0; i < booksize; i++)
  35.     {
  36.       if (0 > fread (&BEND, sizeof (struct bookentry), 1, fd))
  37.         {
  38.           perror ("fread");
  39.           exit (1);
  40.         }
  41. #ifdef notdef
  42.       printf ("%lx %lx %x %d \n", BEND.bookkey, BEND.bookbd, BEND.bmove, BEND.count);
  43. #endif
  44.       if (in && BEND.count)
  45.         {
  46.           c1++;
  47.         }
  48.       else if (BEND.count)
  49.         {
  50.           in = 1;
  51.           c1 = 1;
  52.         }
  53.       else if (c1)
  54.         {
  55.           /*printf ("out %d\n", c1);*/
  56.           n++;
  57.           if (c1 < min)
  58.         min = c1;
  59.           if (c1 > max)
  60.         max = c1;
  61.           sum += c1;
  62.           c1 = 0;
  63.           in = 0;
  64.         }
  65.       sumc += BEND.count;
  66.       if(BEND.count)if(i&1)odd++; else even++;
  67.     }
  68.       fclose (fd);
  69.       if (in)
  70.     {
  71.       /*printf ("out %d\n", c1);*/
  72.       n++;
  73.       if (c1 < min)
  74.     min = c1;
  75.       if (c1 > max)
  76.     max = c1;
  77.       sum += c1;
  78. }
  79.       printf ("max %d\nmin %d\navg %f\nsumc %d\n", max, min, (float) sum / (float) n, sumc);
  80.     printf("odd %d\neven %d\n",even,odd);
  81.  
  82.     }
  83. }
  84.